from dvadmin.models import Dictionary
from util.serializers import CustomModelSerializer
from util.viewset import CustomModelViewSet


class DictionarySerializer(CustomModelSerializer):
    """
    字典-序列化器
    """

    class Meta:
        model = Dictionary
        fields = "__all__"
        read_only_fields = ['id']

class DictionaryCreateUpdateSerializer(CustomModelSerializer):
    """
    字典管理-创建/修改
    """

    class Meta:
        model = Dictionary
        fields = "__all__"


class DictionaryViewSet(CustomModelViewSet):

    queryset = Dictionary.objects.all()
    serializer_class = DictionarySerializer
    extra_filter_backends = []
    search_fields = ['label']